﻿layui.use(['table', 'form', 'layer', 'laypage', 'jquery'], function () {
    var form = layui.form;
    var layer = layui.layer;
    var $ = layui.jquery;
    var table = layui.table;
    var laypage = layui.laypage;

    $('#saveSettingsBtn').on('click', function () {

        var form = {
            afterSalesSetupId: 1,
            roomUpto: $('#roomUpto').val(),
            roomExpenses: 0,
            serviceCharge: 0,
            userSponsor: $('#userSponsor').val(),
            shopSponsor: $('#shopSponsor').val(),
            buySponsor: $('#buySponsor').val()
        }

        $.ajax({
            url: 'http://localhost:5174/api/AfterSale/UpdateAfterSetUp',
            type: 'post',
            contentType: "application/json",
            headers: {
                "Authorization": "Bearer " + localStorage.getItem('token')
            },
            data: JSON.stringify(form),
            success: function (res) {
                if (res > 0) {
                    layer.msg("操作成功")
                }
            },
            error: function (error) {
                console.error(error);
            }
        });

        return false; // 阻止表单的默认提交
    });
});